﻿using CurrentUserDemo.Api.Extensions;
using CurrentUserDemo.Domain.CurrentUsers;

namespace CurrentUserDemo.Api.Infrastructures.CurrentUsers;

public class CurrentUser : ICurrentUser
{
    private readonly IHttpContextAccessor _httpContextAccessor;

    public CurrentUser(IHttpContextAccessor httpContextAccessor)
    {
        _httpContextAccessor = httpContextAccessor;
    }

    public int? GetUserId()
    {
        return _httpContextAccessor.HttpContext?.User?.FindUserId();
    }

    public string? GetUserName()
    {
        return _httpContextAccessor.HttpContext?.User?.FindUserName();
    }
}